import { List,Map } from 'immutable';
import React, { Component } from 'react';
class Immu05 extends Component {
    state={
        info:Map({
            name:"碰磕",
            location:Map({
                province:"江西",
                city:"吉安"
            }),
            hobbit:List(['睡觉','学习','敲键盘'])
        })
    }
    render() {
        return (
            <div>
                <h1>编辑个人信息</h1>
                <div>
                    <button onClick={()=>{
                        this.setState({
                            info:this.state.info.set("name","爱学习").set("location",this.state.info.get("location").set("city","南昌"))
                        })
                    }}>修改</button>
                    {this.state.info.get("name")}
                    <br />
                    {this.state.info.get("location").get("province")}-
                    {this.state.info.get("location").get("city")}
                    {
                        this.state.info.get("hobbit").map((item,index)=><li key={item}>{item}<button onClick={()=>{
                            // console.log(index);
                            this.setState({
                                info:this.state.info.set("hobbit",this.state.info.get("hobbit").splice(index,1))
                            })
                        }}>删除</button></li>)
                    }
                </div>
            </div>
        );
    }
}

export default Immu05;